//
//  SLPopMenuView.m
//  translateAi
//
//  Created by 陈镇 on 2023/5/6.
//

#import "SLPopMenuView.h"

@implementation SLPopMenuView



+(void)showMenuWithView:(UIView *)sender titles:(NSArray<NSString *> *)titles imageNames:(NSArray<NSString *> *)imageNames block:(XHPopMenuItemAction)block{
    
    
    XHPopMenuConfiguration *config = [XHPopMenuConfiguration defaultConfiguration];
    config.hasSeparatorLine = NO;
    config.menuBackgroundColor = UIColorWhite;
    config.alignment = NSTextAlignmentCenter;
    config.shadowColor = UIColorHex(#00000016);
    config.menuMaxHeight = SCREEN_WIDTH;
    config.shadowOfMenu = YES;
    NSMutableArray<__kindof XHPopMenuItem *> *tempArr = [NSMutableArray array];
    for (int i = 0; i < titles.count; i++) {
        
        UIImage *image = nil;
        if(imageNames.count > 0 && i < imageNames.count - 1){
            image = [UIImage imageNamed:imageNames[i]];
        }
        
        
        XHPopMenuItem *model = [[XHPopMenuItem alloc] initWithTitle:titles[i] image:image block:block];
        model.titleFont = SLFontMakeBold(14);
        model.titleColor = UIColorHex(#666666FF);
 
        [tempArr addObject:model];
    }
    
    [XHPopMenu showMenuWithView:sender menuItems:tempArr withOptions:config];
}
@end
